AbortSignal

interface AbortSignal

Cancellation primitive matching the Vercel AI SDK v6 AbortSignal shape.

Per port DECISION 3 (cancellation model): we expose a custom interface that internally wraps Kotlin coroutines Job.cancel(). This gives v6 ergonomics (a propagatable signal threaded through tool execution contexts and subagent calls — invariant I-10) while staying native to Kotlin's structured concurrency.

Idiomatic use: bind to the calling CoroutineScope's job. When the scope cancels, the signal aborts, and any subagent/tool execution observing throwIfAborted or register surfaces the cancellation.

Types

Link copied to clipboard

Properties

Link copied to clipboard
abstract val isAborted: Boolean

True once any cancellation source has fired.

Functions

Link copied to clipboard
abstract fun register(onAbort: () -> Unit): AbortSignal.AbortRegistration

Register a callback that fires exactly once on abort. If already aborted, fires synchronously. Returns a handle to deregister.

Link copied to clipboard
abstract fun throwIfAborted()

Throws AbortError if isAborted. Cheap to call repeatedly.